//
//  MenuViewController.m
//  AwemeDylib
//
//  Created by ted zhang on 2020/4/11.
//  Copyright © 2020 ted zhang. All rights reserved.
//

#import "MenuViewController.h"

@interface MenuViewController ()

@end

@implementation MenuViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    NSLog(@"[CustomView] Inited.");
    NSArray *provinces=[[NSArray alloc] initWithObjects:@"TraceLog OFF",@"AntiAntiDebug ON",@"Capture Network Traffic OFF",@"HTTP Redirect ON -> 192.168.0.117",@"HTTPS Sniffer ON",@"Reveal Proxies ON",@"Resign App ON",@"Collect Hot Author",@"Auto Reply",@"Calculate value of gift",@"Auto Bot",@"Custom Location Settings",@"Operator simulation",@"Upload Server Settings",@"More...", nil];
    self.myData = provinces;
    
    self.tableview.rowHeight = 30;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table View Data source
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:
  (NSInteger)section{
    return [self.myData count]/2;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:
  (NSIndexPath *)indexPath{
    static NSString *cellIdentifier = @"cellID";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:
    cellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc]initWithStyle:
        UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }
    NSString *stringForCell;
    if (indexPath.section == 0) {
        stringForCell= [self.myData objectAtIndex:indexPath.row];

    }
    else if (indexPath.section == 1){
        stringForCell= [self.myData objectAtIndex:indexPath.row+ [self.myData count]/2];

    }
    [cell.textLabel setText:stringForCell];
    return cell;
}

// Default is 1 if not implemented
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 2;
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:
  (NSInteger)section{
    NSString *headerTitle;
    if (section==0) {
        headerTitle = @"Section 1 Header";
    }
    else{
        headerTitle = @"Section 2 Header";

    }
    return headerTitle;
}
- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:
  (NSInteger)section{
    NSString *footerTitle;
    if (section==0) {
        footerTitle = @"Section 1 Footer";
    }
    else{
        footerTitle = @"Section 2 Footer";
        
    }
    return footerTitle;
}

#pragma mark - TableView delegate

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:
 (NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    NSLog(@"Section:%d Row:%d selected and its data is %@",
    indexPath.section,indexPath.row,cell.textLabel.text);
}



/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

- (IBAction)backTo:(id)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (IBAction)showView:(id)sender {
}

- (IBAction)showAlert:(id)sender {
    NSLog(@"Enter testclick.");
    [self btnAlertClick];
    NSLog(@"Leave testclick.");
}

- (void)btnAlertClick {
    UIAlertController* alertView = [UIAlertController alertControllerWithTitle:@"Welcome" message:@"Enjoy Crack." preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"Happy^_^" style:UIAlertActionStyleCancel handler:nil];
    [alertView addAction:cancelAction];
    [self presentViewController:alertView animated:YES completion:nil];
    
    NSLog(@"Print Log Done");
}

@end
